Write-Host "Computer versus man competition on number comparison, ready, set, go!"
while ($true){
    $computerNumber = Get-Random -Minimum 1 -Maximum 101
    $userInput = Read-Host "Enter a number between 1 and 100 (or type 'exit' to quit)"
    
    if ($userInput -eq 'exit') {
        Write-Host "Thanks for playing! Goodbye!"
        break
    }

    if (-not ($userInput -as [int])) {
        Write-Host "Please enter a valid integer."
        continue
    }

    $userNumber = [int]$userInput

    if (($userNumber -lt 1) -or $userNumber -gt 100) {
        Write-Host "Your number is out of range. Please choose a number between 1 and 100."
        continue
    }

    Write-Host "Computer chose: $computerNumber"
    
    if ($userNumber -gt $computerNumber) {
        Write-Host "You win! Your number is greater than the computer's number."
    } elseif ($userNumber -lt $computerNumber) {
        Write-Host "Computer wins! Its number is greater than yours."
    } else {
        Write-Host "It's a tie! Both numbers are equal."
    }
} 